<admintpl file="header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
    	<li><a href="{:U('Admin/Special/specialAdd',array('news_id'=>$news_id,$id_type=>$id_val))}">编辑专题</a></li>
    	<li><a href="{:U('Admin/Special/special_column_index',array('special_id'=>$news_id,$id_type=>$id_val))}">专题分栏</a></li>
        <li class="active"><a href="{:U('Admin/Special/index',array('news_id'=>$news_id,'special_id'=>0,$id_type=>$id_val))}">文章管理</a></li>
    </ul>

    <form class="well form-search" id="query_form" method="post" action="{:U('Admin/Special/index')}">
    	<div>
    		<a href="{:U('Admin/NewsManage/publish', array( 'special_id'=>$news_id,'type'=>'2',$id_type=>$id_val))}" class="btn btn-primary" >快捷发布</a>&nbsp;&nbsp;
	    	<a href="{:U('Admin/NewsManage/pictureAdd', array( 'special_id'=>$news_id,'type'=>'2',$id_type=>$id_val))}" class="btn btn-primary" >图集</a>&nbsp;&nbsp;
	    	<a href="{:U('Admin/NewsVideo/index', array( 'special_id'=>$news_id,'type'=>'2',$id_type=>$id_val))}" class="btn btn-primary" >视频</a>&nbsp;&nbsp;
	    	<!--<a href='{:U("Admin/AdminUser/adminUserAdd")}' class="btn btn-primary" >复制</a>&nbsp;&nbsp;-->
	    	<!--<a href='{:U("Admin/AdminUser/adminUserAdd")}' class="btn btn-primary" >粘贴</a>&nbsp;&nbsp;-->
            <a href="{:U('Admin/Special/nestification',array( 'special_id'=>$news_id,'type'=>'2',$id_type=>$id_val))}" class="btn btn-primary" >嵌套</a>&nbsp;&nbsp;
	    	<a  class="btn btn-primary"  id="newsDel">删除</a>&nbsp;&nbsp;
    	</div>
    	
        <br/><br/>
        
        关键字：<input type="text" name="keyword" style="width: 120px;" value="{$formParam.keyword}" placeholder="请输入文章标题...">
        来源：<input type="text" name="source" style="width: 120px;" value="{$formParam.source}" placeholder="请输入文章来源...">
        编辑：<input type="text" name="creatorName" style="width: 120px;" value="{$formParam.creatorName}" placeholder="请输入编辑者姓名...">
        起始：<input type="text" name="startDate" style="width: 120px;" value="{$formParam.startDate}" placeholder="请选择开始时间...">
        结束：<input type="text" name="endDate" style="width: 120px;" value="{$formParam.endDate}" placeholder="请选择结束时间...">
        权重：<input type="text" name="weight" style="width: 120px;" value="{$formParam.weight}" placeholder="请输入权重...">
        文章类型：
        <select name="type">
        	<option value="" >全部</option>
        	<option value="2" <?php if($formParam['type'] == '2') echo "selected"?>>图集</option>
        	<option value="1" <?php if($formParam['type'] == '1') echo "selected"?>>快捷发布</option>
        	<option value="4" <?php if($formParam['type'] == '4') echo "selected"?>>视频</option>
        </select>
        <input type="hidden" name="news_id" value="{$news_id}">
        <input type="hidden" name="news_id" id="special_news_id" value="{$news_id}">
        <input type="hidden" name="{$id_type}" value="{$id_val}">
        
        <input type="button" name="query_form_btn" id="queryBtn" data-action="{:U('Admin/Special/index')}"  class="btn btn-primary" value="查询"/>
        <br/><br/>
        
    </form>
    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th></th>
                <th>栏目类型</th>
                <th>文章名称</th>
                <th>文章类型</th>
                <th>编辑</th>
                <th>来源</th>
                <th>创建时间</th>
                <th>排序日期</th>
                <th>权重</th>
                <th>打赏</th>
            </tr>
            </thead>
            <tbody>
            <?php $tmp_key = 0;?>
            <foreach name="data" item="vo">
                <tr>
                	<td><input name="news_ids[]"  type="checkbox" value="{$vo.news_id}"></td>
                    <td>{$vo.column_name}</td>
                    <td style="width:800px">
                    
                    
                    <div style="width: 400px;float: left;">
                    <?php 
						if(in_array($vo['type'],array(1,6,7,9,10,11,12,13,14))){
                    ?>
                    	<!--<a href="{:U('Admin/NewsManage/publish', array('news_id'=>$vo['news_id'], 'special_id'=>$news_id,'type'=>'2','type_id'=>$vo['type_id'],$id_type=>$id_val))}">{$vo.title}</a>-->
                        <a href="{:U('Admin/News/editapi', array('news_id'=>$vo['news_id'], 'special_id'=>$news_id, $id_type=>$id_val))}" >{$vo.title}</a>
                    <?php 
                    	}elseif($vo['type'] == '4'){
                    ?>
                    	<!--<a href="{:U('Admin/NewsVideo/index', array('news_id'=>$vo['news_id'], 'special_id'=>$news_id,'type'=>'2','type_id'=>$vo['type_id'],$id_type=>$id_val))}">{$vo.title}</a>-->
                        <a href="{:U('Admin/News/editapi', array('news_id'=>$vo['news_id'], 'special_id'=>$news_id, $id_type=>$id_val))}" >{$vo.title}</a>
                    <?php 
                    	}elseif($vo['type'] == '5'){
                    ?>
                    <!--<a href="{:U('Admin/NewsManage/pictureAdd', array('news_id'=>$vo['news_id'], 'special_id'=>$news_id,'type'=>'2','type_id'=>$vo['type_id'],$id_type=>$id_val))}">{$vo.title}</a>-->
                        <a href="{:U('Admin/News/editapi', array('news_id'=>$vo['news_id'], 'special_id'=>$news_id, $id_type=>$id_val))}" >{$vo.title}</a>
                    <?php
                    	}elseif($vo['type'] == '3'){
                    ?>
                        <a href="{:U('Admin/Special/nestification',array( 'special_id'=>$news_id,'type'=>'2',$id_type=>$id_val,'news_id'=>$vo['news_id']))}">{$vo.title}</a>
                        <?php
                    	}
                    ?>
                    
                    <p style="font-weight:600;">
						<?php 
								  if($vo['type'] == '4'){
									  echo "(";

									        if($vo['video_status'] == '1'){
									            echo "转码中";
									        }elseif($vo['video_status'] == '2'){
									            echo "转码成功";                           
                                            }elseif($vo['video_status'] == '3'){
 									            echo "转码失败";        
                                           } 
                                       else{echo "转码成功";}
                                      echo ")";
                                   }                           
						?>
					</p>
					</div>
					<div style="    padding-top: 5px;">
                    	<span style="float:right;">
                        <?php if(in_array($vo['reference_type'],array(0,2)) && !in_array($vo['type'],array(9,10,11,12,13,14)) ){ ?>
                            <if condition="$vo.special_entry ==1 ">
                                <a href='{:U("Admin/Special/entryDel",array("news_id"=>$vo["news_id"],"special_id"=>$news_id,"id_type"=>$id_type,"id_val"=>$id_val))}' class="btn btn-primary js-ajax-dialog-btn" data-msg="确定要取消入口吗">取消入口</a>

                            <else/>
                                <a href='{:U("Admin/Special/entryAdd",array("news_id"=>$vo["news_id"],"special_id"=>$news_id,"id_type"=>$id_type,"id_val"=>$id_val))}' class="btn btn-primary js-ajax-dialog-btn" >设为入口</a>
                    	    </if>
                        <?php } ?>
                            <if condition="$vo.type neq 3">
                                <input type="button" id="full" value="通栏"  class="btn btn-primary" onclick="setFull('{$vo.news_id}')">
                            </if>
                    	<!--<a href='{:U("Admin/AdminUser/adminUserAdd")}' class="btn btn-primary" >复制url</a>-->
                    	</span>
                    	</div>
                    </td>
                    <td>{$vo.type_zh}</td>
                    <td>{$vo.creator_name}</td>
                    <td>{$vo.source_name}</td>
                    <td>{$vo.create_time}
                           <input type="button" id="refresh" value="刷新" onclick="refresh_news('{$vo.news_id}')" class="btn btn-primary" style="float:right;">
                    </td>
                    <td>{$vo.refresh_time}</td>
                    <td>
                    <input type="text" name="weight" id="weight_{$vo.news_id}" value="{$vo.weight}" disabled="disabled" size="4">
                    <a style="float:right;" id="edit_weight_{$vo.news_id}" href='javascript:void(0);' onclick="update_weight('{$vo.news_id}')"  class="btn btn-primary">修改</a></td>
                        <input type="hidden" name="old_weight" id="old_weight_{$vo.news_id}" value="{$vo.weight}">
                	<td><a href="{:U('Admin/News/news_reward_list',array( 'news_id'=>$vo['news_id']))}" >{$vo.hw_money_total}汇闻币</a></td>   
                </tr>
            </foreach>
            </tbody>
        </table>
    </form>
    <div class="pagination">{$page}</div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
function update_weight(news_id){
    edit_column = $("#edit_weight_"+news_id).html();
    column_befor = $("#old_weight_"+news_id).val();//原权重值
    column  = $("#weight_"+news_id).val(); //现权重值
    now_input_type = $("#weight_" + news_id); //权重 ID
    now_edit_type  = $("#edit_weight_" + news_id);  //修改 按钮ID
    var special_news_id = $("#special_news_id").val();
    if(edit_column == "修改"){
        //处理 同时存在多个input编辑问题
        $(".input_edit").attr("disabled", "disabled");
        $(".edit_sub").html("修改");

        now_input_type.removeAttr("disabled");
        now_edit_type.html("确认");
    }else{
        if(column_befor == column){
            now_input_type.attr("disabled", "disabled");
            now_edit_type.html("修改");
        }else {
            $.post("{:U('newsManage/editWeight')}", {weight: column, news_id: news_id, special_news_id:special_news_id},
                    function (result) {
                        if (result == 1) {
                            now_input_type.attr("disabled", "disabled");
                            now_edit_type.html("修改");
                            location.reload()
                        }else{
                            alert("异常!")
                        }
                    }
            );
        }
    }
    $("#weight"+news_id).removeAttr("disabled");
}

function setFull(news_id){
    var special_news_id = $("#special_news_id").val();
    layer.open({
        type: 2,
        //skin: 'layui-layer-lan',
        title: '通栏设置',
        fix: false,
        shadeClose: true,
        maxmin: true,
        area: ['1000px', '500px'],
        content: "<?php echo U('Admin/NewsManage/setFull')?>"+'&news_id='+news_id+'&special_news_id='+special_news_id,
        end: function(){
            location.reload();
        }
    });
}
function refresh_news(news_id){
    var special_news_id = $("#special_news_id").val();
    $.post("<?php echo U('Admin/NewsManage/refreshNews')?>",{news_id:news_id,special_news_id:special_news_id}, function(result){
        if(result == '1'){
            var msg = '刷新成功';
        }else{
            var msg = '刷新失败';
        }

        alert(msg);
        window.location.reload();
    });
}

    $(document).ready(function () {
        $('input[name="query_form_btn"]').click(function () {
            $('#query_form').attr('action', $(this).attr('data-action'));
            $('#query_form').submit();
        });
    });
    

 $("#newsDel").click(function(){
	 var boxes = $("[name='news_ids[]']");
	 var news_checbox = []
     for(i=0;i<boxes.length;i++){
         if(boxes[i].checked == true){
        	 news_checbox.push(boxes[i].value);
         }
     }
	 
	 if(news_checbox == ''){
		 alert('请选择要删除的文章!');
		 return false;
	 }
     var special_news_id = $("#special_news_id").val();
     $.post("<?php echo U('Admin/Special/newsDel')?>",{
     	news_checbox:news_checbox,special_news_id:special_news_id},function(result){
     	if(result > '0'){
     		var msg = '删除成功';
     	}else{
     		var msg = '删除失败';
     	}
     	
 		alert(msg);
 		location.reload();
       });
 })

</script>
</body>




<!-- 业务管理员页面 -->




